package com.cims.bpm.security.utils.msgdigest;

import org.apache.log4j.Logger;
import org.bouncycastle.crypto.digests.SM3Digest;

/**
 * 消息摘要：国密 sm3
 *
 */
public class Sm3Utils {
	private static Logger logger = Logger.getLogger(Sm3Utils.class);

	public static byte[] digest(byte[] data) {
		SM3Digest sm3 = new SM3Digest();
		byte[] result = null;
		try {
			sm3.update(data, 0, data.length);
			result = new byte[sm3.getDigestSize()];
			sm3.doFinal(result, 0);
		} catch (Exception e) {
			logger.error("Fail: SM3 byte[] to byte[]", e);
		}
		return result;
	}
}
